Making GoogleAssistant CoachBot

I'm going to make a GoogleAssistant interface to CoachBot...



Note its use of Dialogflow/API.AI.

Apr14'2019 create action

  • couldn't get invocation-name CoachBot, settled for Coach Wilson

May05 moving forward.

  • this (from Sept'2017!) is the only thing I can find that talks about integrating with your own existing server app.
  • creating a "conversation" action using Dialogflow.
  • here's the page explaining how to configure "fulfilment" to work via WebHook
    • queryText looks like the raw text entered by user
    • fulfillmentText is a single raw plaintext string that you return, or return fulfillmentMessages as a series of richer elements
    • ooh one element type is card (CardDeck), which can even contain Buttons
    • but just going with list of text bits for now
    • legacy function runs fine locally.
    • made route accept a GET, but can't really submit JSON this way
    • and trying to mimic what Google will POST to it will just be taking something of a guess anyway.
    • so probably best to just deploy and let GoogleAssistant hit it.
    • but is there some good logging to build in? Just did basic input and output lines.

May07 deploy: can I point to it?

  • can use only https:// in fulfillment url when "Google Assistant" integration enabled dammit
  • I guess I'm going to have to try this
  • hmm then do I want to change domain to I gave up on that because you have to use HTTPS for .app domains.

May22 update nginx.conf restart, all works.

sudo apt-get update
sudo: unable to resolve host simplest01
Ign oneiric InRelease
  • edited /etc/hosts
  • different possible issues
  • upgrade Ubuntu
  • CertBot steps now seem to be working
  • until sudo add-apt-repository ppa:certbot/certbot -> sudo: add-apt-repository: command not found
  • realize the Ubuntu upgrade only took me to 12.04.5 LTS so have to upgrade again
  • finish install bits, start actually running CertBot
No names were found in your configuration files. Please enter in your domain
name(s) (comma and/or space separated)  (Enter 'c' to cancel):
Obtaining a new certificate
Performing the following challenges:
http-01 challenge for
http-01 challenge for
nginx: [error] invalid PID number "" in "/run/"
Cleaning up challenges
nginx: [error] invalid PID number "" in "/run/"
Encountered exception during recovery: 
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/certbot_nginx/", line 1141, in nginx_restart
    "nginx restart failed:\n%s\n%s" % (,
certbot.errors.MisconfigurationError: nginx restart failed:
nginx restart failed:
 - Your account credentials have been saved in your Certbot
   configuration directory at /etc/letsencrypt. You should make a
   secure backup of this folder now. This configuration directory will
   also contain certificates and private keys obtained by Certbot so
   making regular backups of this folder is ideal.


  • trying to restart nginx
/etc/init.d/nginx restart
 * Restarting nginx nginx                                                               [fail] 
root@simplest01:~# nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
  • uh-oh I think my edits have been in /opt/nginx/conf/nginx.conf
  • yep
ps aux | grep nginx
root      1012  0.0  0.0   6008   136 ?        Ss   May22   0:00 nginx: master process /opt/nginx/sbin/nginx
  • so why does it smell like the wrong one is running/responding?
  • test my file
nginx -c /opt/nginx/conf/nginx.conf -t
nginx: the configuration file /opt/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /opt/nginx/conf/nginx.conf test is successful
  • otoh that config was never changed by the CertBot process
-rw-r--r-- 1 root root 4802 May 22 06:52 nginx.conf.20190522
-rw-r--r-- 1 root root 4840 May 22 07:00 nginx.conf
  • and neither was the other one!


  • can't stop nginx except with killall -9 nginx
  • then service nginx start
  • seems like all the servers are up, which is weird - maybe needed to kill uwsgi?
  • because getting 404
  • going to kill all those processes - done
  • restart wikigraph and wikiflux - still getting 404 - is it using wrong/raw config?
  • different wrong nginx?
ps aux | grep nginx
root     15209  0.0  0.5  14932  2476 ?        Ss   07:27   0:00 nginx: master process /usr/sbin/nginx
  • kill nginx again
  • try service nginx start -c /opt/nginx/conf/nginx.conf
  • kill/start - but gives me generic "Welcome to nginx" page
  • which config is being used?
  • /usr/sbin/nginx -V 2>&1 | grep --colour=auto conf
  • response includes: --conf-path=/etc/nginx/nginx.conf
  • kill again, try launch /usr/sbin/nginx -c /opt/nginx/conf/nginx.conf
  • now everything is running again, restart remaining uwsgi services - all good
  • but nothing responds to https - ergo all the CertBot stuff did nothing
    • next - see if there's a way to call CertBox with a specific target nginx.conf

Posted to LiNode community forum.

  • which pointed me toward /var/log/letsencrypt/letsencrypt.log


  • reading /var/log/letsencrypt/letsencrypt.log not very helpful, but manually frankenstein my nginx.conf with pieces from inside there, plus notes from here
  • test
nginx -c /opt/nginx/conf/nginx.conf -t
nginx: [emerg] open() "/etc/letsencrypt/le_http_01_cert_challenge.conf" failed (2: No such file or directory) in /opt/nginx/conf/nginx.conf:17
nginx: configuration file /opt/nginx/conf/nginx.conf test failed
  • change that line to use include /etc/letsencrypt/options-ssl-nginx.conf - test again
nginx -c /opt/nginx/conf/nginx.conf -t
nginx: [emerg] BIO_new_file("/opt/nginx/conf/cert.pem") failed (SSL: error:02001002:system library:fopen:No such file or directory:fopen('/opt/nginx/conf/cert.pem','r') error:2006D080:BIO routines:BIO_new_file:no such file)
nginx: configuration file /opt/nginx/conf/nginx.conf test failed
  • hmm which .pem file?
:/etc/letsencrypt# find . -name "*.pem"
./keys/0000_key-certbot.pem - pick this one
  • edit, test
nginx -c /opt/nginx/conf/nginx.conf -t
nginx: [emerg] PEM_read_bio_X509_AUX("/etc/letsencrypt/keys/0000_key-certbot.pem") failed (SSL: error:0906D06C:PEM routines:PEM_read_bio:no start line:Expecting: TRUSTED CERTIFICATE)
nginx: configuration file /opt/nginx/conf/nginx.conf test failed
  • change nginx.conf to use
	ssl_certificate /etc/letsencrypt/csr/0000_csr-certbot.pem;
	ssl_certificate_key /etc/letsencrypt/keys/0000_key-certbot.pem;
  • test
nginx -c /opt/nginx/conf/nginx.conf -t
nginx: [emerg] PEM_read_bio_X509_AUX("/etc/letsencrypt/csr/0000_csr-certbot.pem") failed (SSL: error:0906D06C:PEM routines:PEM_read_bio:no start line:Expecting: TRUSTED CERTIFICATE)
nginx: configuration file /opt/nginx/conf/nginx.conf test failed

Edited: |

blog comments powered by Disqus