Zapier

A data collection flow that connects to a Zapier webhook

https://github.com/meya-ai/community/tree/master/examples/zapierbot

Notable concepts:

  • Multi-step flow that gathers data for use in a Zap
  • Custom component that packages the data and passes it to a Zapier webhook
states:
    name:
        component: meya.input_string
        properties:
            output: name
            text: "What's your name?"
    platform:
        component: meya.input_string
        properties:
            output: mobile_os
            text: Which do you prefer Android or iOS?
    email:
        component: meya.input_string
        properties:
            output: email
            text: "What's your email address?"
    zapier:
        component: zapier
        properties:
            # put your Zapier webhook url here
            webhook: https://zapier.com/hooks/catch/000000/xxxxxxx/
    thanks:
        component: meya.text
        properties:
            text: "Thanks, {{ flow.name }}!"

This is a really simple flow that traverses states in the order that they appear. In this flow, each state collects a piece of data - name, operating system and email.

The data collecting component used here is meya.input_string (a Core Component)

After we've collected all the important data, the next state uses the Zapier component.

# -*- coding: utf-8 -*-
import requests
from meya import Component


class Zapier(Component):

    def start(self):
        url = self.properties.get('webhook')
        data = {
            'name': self.db.flow.get('name'),
            'mobile_os': self.db.flow.get('mobile_os'),
            'email': self.db.flow.get('email')
        }
        response = requests.post(
            url=url,
            json=data)

        return self.respond(message=None, action="next")

The data is retrieved from the datastore and packaged such that it can be passed on to my Zapier webhook. Notice the output properties in the flow match the keys retrieved from the datastore.

🚧

Why is message set to None?

Message is set to None as we don't want a message to be output from this state. The flow ends with a simple meya.text saying "Thanks".