How to autopublished through post request and send email on every post request?

What are you trying to accomplish
I successfully send a post request but It got saved as a draft in builder, Can I make it published automatically when the user submit?.

Also, Can I send an email to the builder admin regarding new review submitted?

Screenshots or video link

Code stack you are integrating Builder with
e.g. NextJS, react

Reproducible code example

`const dataObject = {
    name: slug,
    data: {
      userName: 'Anu',
      review: 'Testing',
      productSlug: slug,
      date: new Date(),
      rating: 4,
    },
  }
  const postData = async (url: string, data: any) => {
    const response = await fetch(url, {
      body: JSON.stringify(data),
      headers: {
        Authorization: 'Bearer ' + process.env.BUILDER_PRIVATE_KEY,
        'Content-Type': 'application/json',
      },
      method: 'POST',
    })

    return response.json()
  }
  postData('https://builder.io/api/v1/write/reviews', dataObject).then(
    (data) => {
      console.log('data: ', data)
    }
  ).catch(error => console.error('error: ', error))
`

@anupama.sharmaa

Yes! You can just pass published: 'published' in your dataObject, like below.

NB: Make sure you only pass supported values to the published field, passing say publish instead of published could result in lost or broken content.

const dataObject = {
    name: 'slug',
    published: 'published',
    data: {
      userName: 'Anu',
      review: 'Testing',
      productSlug: slug,
      date: new Date(),
      rating: 4,
    },
  }

We do not have anything directly from Builder, but you have a few options.

I think the easiest and most straight forward would be to set up some integration within your app with a 3rd party ESP. Whenever the review is submitted to our Write API you could also submit it to the third party as well.

If you want to go through Builder and wait for the Publish event, you could also set up a Webhook on the Reviews model. However, again, you would need to have a third party service to post the data to and which then sends the email.

Hope that helps, let me know if any of those options work for you!