n8n
Learn how to create workflows using Unipile with n8n.
Make triggers with Webhooks
Let say we want to initiate a workflow when a new email is received.
- Set your first step as On webhook call
- Set the HTTP Method to POST.
- Click on Listen for test event
- Now, n8n is waiting for a first event to confirm everything is working. Let's send the event:
- Copy the Test URL
- In Unipile's Dashboard, Add Endpoint from the Webhooks tab.
- Paste the copied value to Endpoint URL.
- Select the event(s) that should trigger the Webhook. For this example, select
email.new. Then save by hitting Add Endpoint. - Refer to Test & Debug webhooks to send a Test event.
- You should now see some output in n8n.
- In Unipile's Dashboard, update the endpoint with the Production URL for production usage.
- You can now use data from the payload of the webhook in the following steps of your workflow.
Make actions with Methods
-
Create a node and search for HTTP Request
-
Select Generic Credential Type in Authentication.
-
Select Header Auth in Generic Auth Type.
-
If you don't have one for Unipile, create a new credentials in Header Auth:
- Create an API Key in Unipile's dashboard
- Copy paste it in Value
- Set Name as X-API-KEY
- Change Header Auth Credential to Unipile API Key
- Save
- Find the method you want to use in the API Reference
- Set the proper URL and Method. For this example, we'll use Send a Message : set https://api.unipile.com/v2/account_id/chats/chat_id/messages/send as URL and POST as Method. Of course, set
account_idandchat_idto your needs. Note that they can be dynamically retrieved from other nodes, refer to the n8n documentation to learn about that.
- If you need to pass Query Params, check Send Query Parameters and specify them in the fields below. For exemple the offset of List all Chats :
- If you need to pass Body Params, check Send Body and specify them in the fields below. For exemple with Send a message :
- Refer to the n8n documentation to handle the result.
Control cache on requests
Unipile support the Cache-Control standard request header and few of its directives to control the Caching when you make a request on Methods API. You can add this header on your request configuration by checking Send Headers
Updated 2 months ago