Identify Picture
@raymondcamden
code:
data:privatelast updated:3 years ago
today
Build integrations remarkably fast!
You're viewing a public workflow template.
Sign up to customize, add steps, modify code and more.
Join 800,000+ developers using the Pipedream platform
steps.
trigger
active
last updated:-last event:-
steps.
checkimage
auth
to use OAuth tokens and API keys in code via theauths object
code
Write any Node.jscodeand use anynpm package. You can alsoexport datafor use in later steps via return or this.key = 'value', pass input data to your code viaparams, and maintain state across executions with$checkpoint.
async (event, steps) => {
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
}
36

if(steps.trigger.event.MediaUrl0) {
  const fetch = require('node-fetch');

  let img = steps.trigger.event.MediaUrl0;
  console.log('going to process image: ',img);

  let info = {
    url:img
  };
  

  let resp = await fetch(`${process.env.MS_COG_EP}/vision/v3.1/analyze?visualFeatures=Categories,Description`,{
    method:'POST',
    headers:{
      'Content-Type':'application/json',
      'Accept':'application/json',
      'Ocp-Apim-Subscription-Key': process.env.MS_COG_KEY
    },
    body:JSON.stringify(info)
  });
  let data = await resp.json();
  this.text = `

I parsed your image and found: ${data.description.captions[0].text}

Here's other things I noted: ${data.description.tags.join(', ')}
  `;
  
} else {
  this.text = `
  To use this service, please text a picture to me.
  `
}
steps.
send_new_message
Sends a new SMS message
auth
(auths.twilio)
params
To

The destination phone number. Format with a '+' and country code e.g., +16175551212 (E.164 format).

 
string ·params.To
From

A Twilio phone number (in E.164 format) or alphanumeric sender ID enabled for the type of message you wish to send. Phone numbers or short codes purchased from Twilio work here. You cannot (for example) spoof messages from your own cell phone number.

 
string ·params.From
Body

The text of the message you want to send, limited to 1600 characters.

 
string ·params.Body
Optional
code
async (params, auths) => {
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
}
38
// Read the Twilio docs at https://www.twilio.com/docs/sms/api/message-resource#create-a-message-resource
const phone = require('phone');

// Parse the given number into its E.164 equivalent
// The E.164 phone number will be included in the first element
// of the array, but the array will be empty if parsing fails.
// See https://www.npmjs.com/package/phone
const toParsed = phone(params.To)
if (!toParsed.length) {
  throw new Error(`Phone number ${params.To} couldn't be parsed as a valid number.`)
}
const fromParsed = phone(params.From)
if (!fromParsed.length) {
  throw new Error(`Phone number ${params.From} couldn't be parsed as a valid number.`)
}

const data = {
  To: toParsed[0],
  From: fromParsed[0],
  MessagingServiceSid: params.MessagingServiceSid,
  Body: params.Body,
  MediaUrl: params.MediaUrl,
}
const config = {
  method: "post",
  url: `https://api.twilio.com/2010-04-01/Accounts/${auths.twilio.AccountSid}/Messages.json`,
  headers: {
    "Content-Type": "application/x-www-form-urlencoded",
  },
  auth: {
    username: auths.twilio.Sid,
    password: auths.twilio.Secret,
  },
  data: require("qs").stringify(data),
}
return await require("@pipedreamhq/platform").axios(this, config)