If you're trying to do this, you came to the right place!
See this code in action here: https://twitter.com/CodingDoug/status/953031540811825152
-
Create a Firebase project at the Firebase Console
-
Create a Dialogflow agent the Dialogflow console that uses the Firebase project that was just created (select it from the dropdown).
-
Import the prebuilt agent called "Translate" by selecting "Prebuilt Agents" on the left and scrolling down to find "Translate". This will create some intents automatically - you don't have to create any intents or entities. Take a look at them to see how conversation works.
-
Using the Firebase CLI, initialize a new project space with Functions, and select the Firebase project you created earlier.
-
Install the Actions on Google and Cloud Translate API libraries for node:
cd functions npm install actions-on-google @google-cloud/translate
-
Edit
functions/src/index.ts
and copy the code fromindex.ts
in this gist into it, replacing its contents. -
Deploy the function with
firebase deploy
-
In the deployment output, copy the function URL. It will look something like this:
https://us-central1-your-project.cloudfunctions.net/fulfill
-
In the Dialogflow console, select "Fulfillment" on the left,enable the webhook with the switch, then paste the function URL into the URL field.
-
Select "Intents" on the left. For every intent that was imported, select it, scroll to the very bottom, check the "Use webhook" checkbox under "Fulfillment", and click "Save" at the top.
-
In the Google Cloud console for your Firebase project, enable the Cloud Translate API. This requires billing to be enabled on your project.
(If you don't enable this API, then first time the translate API is called by your function, it will leave an error in the Functions log with a URL to follow to enable the Google Cloud Translate API. Copy that URL and load it into your browser to enable the API.)
-
At this point, you should be able to type translation requests using the Dialogflow test panel on the right in the Dialogflow console.
-
Create a workspace in Slack, or use an existing workspace.
-
To enable Slack integration with Dialogflow, choose "Integrations" on the left, then enable Slack. Follow the instructions and give permission to Dialogflow to operate a bot on your workspace.
-
When you enable the test bot, it should appear as an app in your Slack workspace with the name "Dialogflow Bot". You can direct message this bot to get translations.